package com.smart_campus.sys.controller;

import com.smart_campus.sys.common.DataGridView;
import com.smart_campus.sys.common.ResultObj;
import com.smart_campus.sys.service.LoginfoService;
import com.smart_campus.sys.vo.LoginfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @aytgor 陈鹏
 * @date 2020/6/7 19:29
 * 日志controller
 */
@RestController
@RequestMapping("loginfo")
public class LoginfoController {
    @Autowired
    private LoginfoService loginfoServices;

    /**
     * 查询全部日志数据
      我的意思是这里的请求动作
     * @param loginfoVo
     * @return DataGridView
     */
    @RequestMapping(value = "loadAllLoginfo",method = RequestMethod.GET)
    public DataGridView loadAllLoginfo(LoginfoVo loginfoVo) {
        return loginfoServices.selectloginfo(loginfoVo);
    }

    /**
     * 批量删除日志
     *
     * @param ids
     * @return ResultObj
     */
    @RequestMapping("DeleteBatchLoginfo")
    public ResultObj DeleteBatchLoginfo(Integer[] ids) {
        try {
            for (Integer id : ids) {
                loginfoServices.deleteByPrimaryKey(id);
            }
            return ResultObj.DELETE_IOGINFO_YES;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_IOGINFO_NO;
        }
    }


    /**
     * 删除日志
     *
     * @param loginfoid
     * @return DeleteLoginfo
     * 11
     */
    @RequestMapping("DeleteLoginfo")
    public ResultObj DeleteLoginfo(Integer loginfoid) {
        try {
            loginfoServices.deleteByPrimaryKey(loginfoid);
            return ResultObj.DELETE_IOGINFO_YES;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_IOGINFO_NO;
        }
    }
}
